package corej.course.thread;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class ChatClient {
    public static void main(String[] args) {
        JFrame frame = new JFrame("Chat Client");
        frame.setSize(400, 300);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        final JTextArea jta = new JTextArea();
        final JTextField jtf = new JTextField();
        frame.add(new JScrollPane(jta));
        frame.add(jtf, "South");

        jta.setEditable(false);

        frame.setVisible(true);

        jtf.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                String text = jtf.getText();
                jtf.setText("");
                jta.append(text + "\n");
            }
        });
    }
}
